#include "ScrollButtonDown.h"


ScrollButtonDown::ScrollButtonDown(SDL_Surface* screen, int x, int y, int w, int h, ListTextBox* lista) {
	this->screen = screen;
	this->box.x = x;
	this->box.y = y;
	this->box.w = w;
	this->box.h = h;
	this->lista = lista;
	this->image = NULL;
	this->image = SDL_LoadBMP("down.bmp");

}


ScrollButtonDown::~ScrollButtonDown(void)
{
}

void ScrollButtonDown::draw(){
	if(image == NULL)
		this->drawBox();
	else
		SDL_BlitSurface(this->image, NULL, screen, &this->box);

}

bool ScrollButtonDown::drawBox(void) {
	return SDL_FillRect(this->screen, &this->box, 0xFFFFFF);
}

void ScrollButtonDown::handleEvent(SDL_Event* ev){
	if(ev->type == SDL_MOUSEBUTTONDOWN && ev->button.button == SDL_BUTTON_LEFT) {
        int x = ev->button.x;
        int y = ev->button.y;
		//Verificacion de click sobre el boton.
		if(x < this->box.w+this->box.x && x > this->box.x && y < this->box.h + this->box.y && y > this->box.y) {
			this->lista->scrollDown();
		}
	}
}